﻿Imports System
Imports System.ComponentModel.Design

Namespace System.Workflow.ComponentModel.Design
    Friend NotInheritable Class CommandSetItem
        Inherits MenuCommand
        ' Methods
        Public Sub New(ByVal statusHandler As EventHandler, ByVal invokeHandler As EventHandler, ByVal id As CommandID)
            MyBase.New(invokeHandler, id)
            Me.statusHandler = statusHandler
        End Sub

        Public Sub New(ByVal statusHandler As EventHandler, ByVal invokeHandler As EventHandler, ByVal id As CommandID, ByVal immidiateStatusUpdate As Boolean)
            Me.New(statusHandler, invokeHandler, id)
            Me.immidiateStatusUpdate = immidiateStatusUpdate
        End Sub

        Public Sub New(ByVal statusHandler As EventHandler, ByVal invokeHandler As EventHandler, ByVal id As CommandID, ByVal [text] As String)
            Me.New(statusHandler, invokeHandler, id)
            Me.Properties.Item("Text") = [text]
        End Sub

        Public Sub UpdateStatus()
            If (Not Me.statusHandler Is Nothing) Then
                Try 
                    Me.statusHandler.Invoke(Me, EventArgs.Empty)
                Catch obj1 As Object
                End Try
            End If
        End Sub


        ' Properties
        Public Overrides ReadOnly Property OleStatus As Integer
            Get
                If Me.immidiateStatusUpdate Then
                    Me.UpdateStatus
                End If
                Return MyBase.OleStatus
            End Get
        End Property


        ' Fields
        Private immidiateStatusUpdate As Boolean
        Private statusHandler As EventHandler
    End Class
End Namespace

